Skip to content

Fix #4260 : Allow trailing arguments that accept void to be omitted - #27522

Merged
Ryan Cavanaugh (RyanCavanaugh) merged 2 commits into
microsoft:masterfrom
jack-williams:trailing-void-args-are-optional
Oct 19, 2018
Merged

Fix #4260 : Allow trailing arguments that accept void to be omitted #27522
Ryan Cavanaugh (RyanCavanaugh) merged 2 commits into
microsoft:masterfrom
jack-williams:trailing-void-args-are-optional

Conversation

@jack-williams

Copy link
Copy Markdown
Collaborator

Fixes #4260

@RyanCavanaugh

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Oct 3, 2018

Copy link
Copy Markdown
Contributor

Heya Ryan Cavanaugh (@RyanCavanaugh), I've started to run the extended test suite on this PR at 2b44a1b. You can monitor the build here. It should now contribute to this PR's status checks.

@RyanCavanaugh

Copy link
Copy Markdown
Member

Jack Williams (@jack-williams) FYI I expect the test run from the bot to fail so don't get worried if it comes back red

@jack-williams

Copy link
Copy Markdown
Collaborator Author

No worries! Thanks for picking it up

Comment thread src/compiler/checker.ts Outdated
@jack-williams

Copy link
Copy Markdown
Collaborator Author

This doesn't fix something like:

declare function foo<T = void>(x: T);
foo(); // T = void, expected 1 arg, 0 given

which I actually think is one of the more useful scenarios. I disabled this behavior because otherwise it means you have to do arity checking again after instantiation which messes with overloading. I'm wondering if we could put in a special case for 1 signature? If it's seems useful enough that is.

@RyanCavanaugh

Copy link
Copy Markdown
Member

Jack Williams (@jack-williams) I don't find that example super compelling given that it potentially requires multiple iterations of reasoning, e.g.

type MaybeVoid = T extends void ? void : object;
declare function foo<T = void>(x: T, y: MaybeVoid<T>);
foo();

@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) merged commit b64d08a into microsoft:master Oct 19, 2018
@jack-williams

Copy link
Copy Markdown
Collaborator Author

Ryan Cavanaugh (@RyanCavanaugh) Ye I’m inclined to agree. Thanks for merging!

@DanielRosenwasser

Copy link
Copy Markdown
Member

Tags: void parameters void-typed parameters optional

@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants